package com.crm.jdy.controller.client;

import com.crm.jdy.common.dto.CallAplanInfoDto;
import com.crm.jdy.common.pojo.ActivitiBasuness;
import com.crm.jdy.common.pojo.BasunessMessage;
import com.crm.jdy.common.pojo.CallAplanInfo;
import com.crm.jdy.common.utils.api.ResultVo;
import com.crm.jdy.common.utils.currentlimiting.RateLimit;
import com.crm.jdy.service.client.ActivitiBasunessService;
import com.crm.jdy.service.client.BasunessMessageService;
import com.crm.jdy.service.client.CallAplanInfoService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
*
* <p>说明： 工作流对应的审批信息API接口层</P>
* @version: V1.0
* @author: kong
* @time    2021年3月29日
*
*/
@Validated
@Api(tags = "basunessMessage", description = "工作流对应的审批信息")
@RestController
@RequestMapping("/basunessMessage")
public class BasunessMessageController{

    @Reference(version = "${service.version}", check = false)
    BasunessMessageService basunessMessageService;

    @RateLimit()
    @ApiOperation("批量添加工作流携带的审批信")
    @PostMapping("/addAllBasunessMessage")
    public ResultVo addBasunessMessage(@ApiParam(name = "basuness", required = false)
                                       @RequestBody List<BasunessMessage> basuness){
        boolean list  = basunessMessageService.addAllActivitiBasuness(basuness);
        return  ResultVo.success(list);
    }

    @RateLimit()
    @ApiOperation("工作流携带的审批信息")
    @PostMapping("/seleteBasunessMessage")
    public ResultVo seleteBasunessMessage( @RequestBody BasunessMessage basunessMessage){
        List<BasunessMessage> list = basunessMessageService.seleteBasunessMessage(basunessMessage);
        return  ResultVo.success(list);
    }


    @RateLimit()
    @ApiOperation("更新流程附带的信息")
    @PostMapping("/updatBasunessMessage")
    public ResultVo updatBasunessMessage(@ApiParam(value = "basunessMessage", required = true)
                                         @Validated @RequestBody BasunessMessage basunessMessage){
        boolean index = basunessMessageService.updateBasunessMessage(basunessMessage);
        if(index){
            return  ResultVo.success();
        }
        return  ResultVo.failed();
    }

    @RateLimit()
    @ApiOperation("添加流程附带的信息")
    @PostMapping("/addBasunessMessage")
    public ResultVo addBasunessMessage(@ApiParam(name = "basunessMessage", required = false)
                                       @Validated @RequestBody BasunessMessage basunessMessage){
        boolean list  = basunessMessageService.addBasunessMessage(basunessMessage);
        return  ResultVo.success(list);
    }

    @RateLimit()
    @ApiOperation("删除流程附带的信息")
    @DeleteMapping("deleteBasunessMessage")
    public ResultVo deleteBasunessMessage(@NotNull @ApiParam(name = "basunessMessage", required = false)
                                           @RequestBody  BasunessMessage basunessMessage){
        boolean b = basunessMessageService.removeBasunessMessage(basunessMessage);
        if(b){
            return ResultVo.success();
        }
        return ResultVo.failed();
    }


}